export function formatTime(timestamp: number | string, withSeconds = true): string {
    const ts = Number(timestamp)
    const date = new Date(ts.toString().length === 10 ? ts * 1000 : ts)
    const Y = date.getFullYear()
    const M = String(date.getMonth() + 1).padStart(2, '0')
    const D = String(date.getDate()).padStart(2, '0')
    const h = String(date.getHours()).padStart(2, '0')
    const m = String(date.getMinutes()).padStart(2, '0')
    const s = String(date.getSeconds()).padStart(2, '0')

    return withSeconds ? `${Y}-${M}-${D} ${h}:${m}:${s}` : `${Y}-${M}-${D} ${h}:${m}`
}
